//
//  UIImageView-Extension.swift
//  MyTouTiao
//
//  Created by Yuri on 2018/3/20.
//  Copyright © 2018年 Yuri. All rights reserved.
//

import Foundation
import Kingfisher

extension UIImageView {
    //设置占位图片显示
    func dlm_setImage(url: String?, placeHolderImageType: PlaceHolderImageType) {
        if placeHolderImageType == .userAvatar  {
            kf.setImage(with: URL(string: url ?? ""), placeholder: UIImage(named: "user_photo_default"))
        }else {
            kf.setImage(with: URL(string: url ?? ""), placeholder: UIImage(named: "c_placehold"))
        }
    }
}

/// 占位图片的类型
///
/// - currency: 最通用的类型
/// - userAvatar: 用户头像
enum PlaceHolderImageType: Int {
    case currency
    case userAvatar
    
    // 默认图片name
    var imageName: String {
        switch self {
        case .currency:
            return ""
        case .userAvatar:
            return "user_photo_default"
        }
    }
}
